package com.ecommerce.common;

/**
 * 响应状态码枚举
 * 
 * @author ecommerce-team
 * @version 1.0.0
 */
public enum ResultCode {
    
    // 通用状态码
    SUCCESS(200, "操作成功"),
    ERROR(500, "操作失败"),
    PARAM_ERROR(400, "参数错误"),
    UNAUTHORIZED(401, "未授权"),
    FORBIDDEN(403, "禁止访问"),
    NOT_FOUND(404, "资源不存在"),
    
    // 商品相关状态码 (404xxx)
    PRODUCT_NOT_FOUND(404001, "商品不存在"),
    PRODUCT_STOCK_INSUFFICIENT(404002, "商品库存不足"),
    PRODUCT_SPEC_NOT_FOUND(404003, "商品规格不存在"),
    PRODUCT_OFFLINE(404004, "商品已下架"),
    
    // 用户相关状态码 (401xxx)
    USER_NOT_LOGIN(401001, "用户未登录"),
    USER_NOT_FOUND(401002, "用户不存在"),
    USER_DISABLED(401003, "用户已被禁用"),
    
    // 订单相关状态码 (402xxx)
    ORDER_NOT_FOUND(402001, "订单不存在"),
    ORDER_STATUS_ERROR(402002, "订单状态错误"),
    ORDER_CANNOT_CANCEL(402003, "订单无法取消"),
    
    // 支付相关状态码 (403xxx)
    PAYMENT_FAILED(403001, "支付失败"),
    PAYMENT_TIMEOUT(403002, "支付超时"),
    PAYMENT_AMOUNT_ERROR(403003, "支付金额错误"),
    
    // 系统相关状态码 (500xxx)
    SYSTEM_ERROR(500001, "系统内部错误"),
    DATABASE_ERROR(500002, "数据库操作失败"),
    NETWORK_ERROR(500003, "网络连接异常");
    
    private final Integer code;
    private final String message;
    
    ResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
    
    public Integer getCode() {
        return code;
    }
    
    public String getMessage() {
        return message;
    }
}